<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>简介</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.stream.html">Streams</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="stream.setup.html">安装／配置</a></div>
 <div class="up"><a href="book.stream.html">Streams</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intro.stream" class="preface">
   <h1 class="title">简介</h1>
   <p class="simpara">
    Streams were introduced with PHP 4.3.0 as
    a way of generalizing file, network, data compression, and other
    operations which share a common set of functions and uses.  In
    its simplest definition, a <em>stream</em> is a 
    <em>resource</em> object which exhibits streamable 
    behavior.  That is, it can be read from or written to in a linear 
    fashion, and may be able to <span class="function"><a href="function.fseek.html" class="function">fseek()</a></span> to an
    arbitrary locations within the stream.
   </p>
   <p class="simpara">
    A <em>wrapper</em> is additional code which tells the stream how to handle
    specific protocols/encodings.  For example, the <em>http</em>
    wrapper knows how to translate a URL into an <em>HTTP/1.0</em>
    request for a file on a remote server.  There are many wrappers
    built into PHP by default (See <a href="wrappers.html" class="xref">支持的协议和封装协议</a>),
    and additional, custom wrappers may be added either within a
    PHP script using <span class="function"><strong>stream_wrapper_register()</strong></span>,
    or directly from an extension using the API Reference in <a href="internals2.streams.html" class="xref">流的使用</a>.
    Because any variety of wrapper may be added to PHP, 
    there is no set limit on what can be done with them.  To access the list
    of currently registered wrappers, use <span class="function"><a href="function.stream-get-wrappers.html" class="function">stream_get_wrappers()</a></span>.
   </p>
   <p class="para">
    A stream is referenced as: <em><code class="parameter">scheme</code></em>://<em><code class="parameter">target</code></em>
    <ul class="itemizedlist">
     <li class="listitem">
      <span class="simpara">
       <em><code class="parameter">scheme</code></em>(string) -
       The name of the wrapper to be used.  Examples include: file, 
       http, https, ftp, ftps, compress.zlib, compress.bz2, and php.  See 
       <a href="wrappers.html" class="xref">支持的协议和封装协议</a> for a list of PHP built-in wrappers.  If
       no wrapper is specified, the function default is used (typically
       <em>file</em>://).
      </span>
     </li>
     <li class="listitem">
      <span class="simpara">
       <em><code class="parameter">target</code></em> - 
       Depends on the wrapper used.  For filesystem related streams this is
       typically a path and filename of the desired file.  For network related 
       streams this is typically a hostname, often with a path appended.  Again, see
       <a href="wrappers.html" class="xref">支持的协议和封装协议</a> for a description of targets for built-in streams.
      </span>
     </li>
    </ul>
   </p>
   <p class="para">
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
      Information on using streams within the PHP source code can be found in the
      <a href="internals2.ze1.streams.html" class="link">Streams API for PHP Extension Authors reference</a>.
     </p>
    </p></blockquote>
   </p>
  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.stream.html">Streams</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="stream.setup.html">安装／配置</a></div>
 <div class="up"><a href="book.stream.html">Streams</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
